package conson.tech.manage.message.service.impl;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import conson.tech.manage.common.util.EntityUtils;
import conson.tech.manage.message.entity.pojo.MessageConfig;
import conson.tech.manage.message.entity.vo.MessageConfigVo;
import conson.tech.manage.message.entity.vo.PageVo;
import conson.tech.manage.message.mapper.MessageConfigMapper;
import conson.tech.manage.message.service.MessageConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * ClassName: MessageConfigServiceImpl
 * Description:
 * Author: HXL
 * Date: 2020/4/22 9:50 上午
 * Version: 1.0
 */
@Service("messageConfigService")
public class MessageConfigServiceImpl implements MessageConfigService {
    @Autowired
    private MessageConfigMapper messageConfigMapper;
    @Override
    @Transactional
    public int createMessage(MessageConfig config) {
        return messageConfigMapper.insert(config);
    }

    @Override
    public Page<MessageConfigVo> queryMessagePage(PageVo vo) {
        Page<MessageConfig> page = new Page();
        page.setCurrent(vo.getPageIndex());
        page.setSize(vo.getPageSize());
        Page<MessageConfig> dtoPage = messageConfigMapper.queryMessagePage(page,vo.getId());
        Page<MessageConfigVo> adPage = new Page<>();
        if (dtoPage != null) {
            return EntityUtils.pageToPage(dtoPage, MessageConfigVo.class);
        }
        return adPage;
    }
}
